
navbarApp.controller('contest_work_list_controller', function ($scope, $http) {0

    //初始化 查询条件
    var searchDefaultVal = {
        categoryId:'',
        stepId:'',
        privacy:'',
        state:'',
        queryNameShow:'',
        queryName:'',
        queryValue:'',
        prizeId:'',
        medal:''
    }
    $scope.searchResult = angular.copy(searchDefaultVal);//初始化查询条件


    //查询状态记录
    $scope.searchQueryValueSend = '';
    $scope.isSearchAdditional = false;




    //作品奖项列表 查询条件 $scope.resourceId_prizeTable
    $scope.resource_prizeTable = null; //当前作品信息
    $scope._host = host;  //当前web域名（shijue.me /vcg-design.shijue.me）
    $scope.cur_contest = null; //当前大赛信息
    //下发奖项设置的数据对象

    $scope.objAddPrize =
    {
        resourceId: '',
        categoryId: '',
        stepId: '',
        prizeId: ''
    }
    $scope.isModifyPrize = false;



    //重置查询条件
    $scope.resetSearch = function(){
        console.log(searchDefaultVal);
        $scope.searchResult = angular.copy(searchDefaultVal);
        $scope.refreshWorkMaintenanceList();
    }



    //获取列表数据
    $scope.getWorkMaintenanceList = function(){
        $scope.isSearchAdditional = true;
        $scope.searchQueryValueSend = angular.copy($scope.searchResult.queryValue);//拷贝一份，脱离数据绑定
        $("#dataTable").dataTable().fnDraw();
    }
    $scope.refreshWorkMaintenanceList = function(){
        $("#dataTable").dataTable().fnDraw();
    }
    //设置附加查询条件
    $scope.setSearchType = function(qName, qNameShow){
        $scope.searchResult.queryName = qName;
        $scope.searchResult.queryNameShow = qNameShow;
    }

    //导出表格数据的url
    $scope._exportUrl = '';

    //大赛详情链接
    $scope._contestDetailLink = '';


    //授予勋章
    $scope.getWorkMedal = function (resourceId, contestId, prizeMsg) {
        $http.post('http://node.shijue.me/contests/contest/addHonor', {
            resourceId: resourceId,
            contestId: contestId,
            prizeMsg: prizeMsg
        }).success(function (rData) {
            $("#dataTable").dataTable().fnDraw();
        });
    };

    //剥夺勋章
    $scope.setWorkMedal = function (resourceId) {
        $http.post('http://node.shijue.me/contests/contest/deleteHonor', {resourceId: resourceId}).success(function (rData) {
            $("#dataTable").dataTable().fnDraw();
        });
    };

    //显示详细信息
    $scope.showDetail = function(resourceId){
        $http.post('/contests/contest/v2/mantance/detail',{resourceID:resourceId}).success(function(rData){
            var data = rData.data;
            $scope.detail = {
                user : data.userInfo,
                address : data.userInfo.address?data.userInfo.address:'' + "  " +  data.userInfo.area?data.userInfo.area:'',
                title : data.title,
                picCount : data.picCount,
                createdTime : new Date(data.createdTime).pattern('yyyy-MM-dd HH:mm:ss')
            }
            $('#myModal').modal('show');
        });
    }

    //退赛
    $scope.quitContest = function(resourceId, contestId){
        layer.confirm('确定退赛?', {icon: 3, title:'提示'}, function(index){
            $http.post('/contests/contest/v2/mantance/doQuit',{resourceId:resourceId, contestId:contestId}).success(function(rData){
                if(rData.status == '200'){
                    layer.msg('退赛成功', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        //var curPage = $("#dataTable").DataTable().page();
                        //$("#dataTable").DataTable().page(curPage).draw('page');
                        $("#dataTable").dataTable().fnDraw();
                    });
                }
            });
        })
    }


    //公开/隐藏作品
    $scope.setWorkPrivacy = function(resourceId,contestId, privacy){
        var confirmStr = '确认公开此作品?';
        if(privacy == 2){//隐藏
            confirmStr = '确认隐藏此作品?';
        }
        layer.confirm(confirmStr, {icon: 3, title:'提示'}, function(index){
            $http.post('/contests/contest/v2/mantance/hide',{resourceIdStr:resourceId, contestId:contestId, privacy:privacy}).success(function(rData){
                if(rData.status == '200'){
                    layer.msg(((privacy == 2)?'隐藏':'公开') + '成功', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        //var curPage = $("#dataTable").DataTable().page();
                        //$("#dataTable").DataTable().page(curPage).draw('page');
                        $("#dataTable").dataTable().fnDraw();
                    });
                }
            });
        })

    }



    //奖项设置时 选择分类
    $scope.select_category = function() {
        $scope.cur_prizes = angular.copy($scope.cur_contest.prizes);
        for (var i = 0; i < $scope.cur_prizes.length; i++) {
            if ($scope.objAddPrize.categoryId != $scope.cur_prizes[i].contestCategoryId) {
                $scope.cur_prizes.splice(i, 1);
                i--;
            }
        }

    }
    $scope.validIsSelectCate = function(){
        if (!$scope.objAddPrize.categoryId) {
            layer.msg('请先选择分类');
            return;
        }else{
            return true;
        }
    }


    //添加奖项  $("#myModal-prize-set").dataTable().fnDraw();
    $scope.addPrize = function(){
        layer.confirm('确认添加该奖项?', {icon: 3, title:'提示'}, function(index){
            $http.post('/contests/contest/v2/mantance/addShow',
                $scope.objAddPrize).success(function(rData){
                if(rData.status == '200'){
                    layer.msg('添加奖项成功', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        //var curPage = $("#dataTable").DataTable().page();
                        //$("#dataTable").DataTable().page(curPage).draw('page');
                        $scope.isModifyPrize = true;
                        $("#dataTable-prize-list").dataTable().fnDraw();
                    });
                }
            });
        })
    }

    //撤奖
    $scope.deletePrize = function(showId){
        layer.confirm('确认撤销该奖项?', {icon: 3, title:'提示'}, function(index){
            $http.post('/contests/contest/v2/mantance/deleteShow',{showId:showId}).success(function(rData){
                if(rData.status == '200'){
                    layer.msg('撤销奖项成功', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        //var curPage = $("#dataTable").DataTable().page();
                        //$("#dataTable").DataTable().page(curPage).draw('page');
                        $scope.isModifyPrize = true;
                        $("#dataTable-prize-list").dataTable().fnDraw();
                    });
                }
            });
        })
    }




    //设置奖项
    $scope.setPrizeShowWin = function(recourceId, contestId){
        if($.fn.dataTable.isDataTable('#dataTable-prize-list')){//有可能之前已经初始化过该表格了
            $("#dataTable-prize-list").dataTable().fnDraw();
        }else {
            $scope.initPrizeList();
        }
        $("#myModal-prize-set").modal('show');
        //$http({
        //    url:'/contests/contest/v2/mantance/resPrizeInfo',
        //    method:'post',
        //    data:{
        //        resourceId: recourceId,
        //        contestId: contestId
        //    }
        //}).success(function(data){
        //    $scope.initPrizeList();
        //    $("#myModal-prize-set").modal('show');
        //});
    }

    $scope.closePrizeSetWin = function(){
        //isModifyPrize
        $("#myModal-prize-set").modal('hide');
        if($scope.isModifyPrize){
            $("#dataTable").dataTable().fnDraw();
        }
    }

    //初始化奖项列表
    $scope.initPrizeList = function(){
        $('#dataTable-prize-list').dataTable({
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "",//(由 _MAX_ 项结果过滤)
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            },
            /*aoColumns:[ //设定各列宽度
             {"sWidth": "10%"},
             {"sWidth": "30%"},
             {"sWidth": "30%"},
             {"sWidth": "30%"}
             ],
             <th>大赛名称</th>
             <th>创建时间</th>
             <th>作品数量</th>
             <!--<th>参赛人数</th>-->
             <th>当前状态</th>
             <th>推荐</th>
             <th>权重</th>
             <th>管理</th>*/
            columns: [
                {title: '阶段', data: 'stepName', "mRender" : function(data, type, full) {
                    return data?data:'--';
                }},
                {title: '类别',data: 'categoryName', "mRender" : function(data, type, full) {
                    return data?data:'--';
                }},
                {
                    title: '奖项', data: 'prizeName', "mRender" : function(data, type, full) {
                    return data?data:'--';
                }},
                {
                    title : '操作',
                    "data": null,
                    "orderable": false,
                    //"defaultContent": "<button>删除</button>&nbsp;<button>编辑</button>",
                    createdCell: function (td, cellData, rowData, row, col) {
                        $(td).html('');
                        var deleteEl = $('<a class="btn btn-danger btn-xs btn-line" style="margin-top: 0">撤奖</a>');

                        $(td).append(deleteEl);


                        deleteEl.click(function(){
                            $scope.deletePrize(rowData.id);
                        });
                    }
                }
            ],
            "bSort": false,
            "bProcessing": true, //加载数据时显示正在加载信息
            "bServerSide": true, //指定从服务器端获取数据
            "bFilter": false, //不使用过滤功能
            "bLengthChange": false, //用户不可改变每页显示数量
            "iDisplayLength": 16, //每页显示10条数据
            "sAjaxSource": '/contests/contest/v2/mantance/resPrizeInfo',
            "fnServerParams" : function (aoData) {
                var pageSize = aoData[4].value;
                var pageIndex = aoData[3].value/pageSize+1;
                aoData.push(
                    {"name":"contestId","value":$.getUrlParam('contestId')},
                    {"name":"page","value":pageIndex},
                    {"name":"size","value":pageSize},
                    { "name": "resourceId", "value": $scope.resource_prizeTable.id}
                );
            },
            "fnServerData": function( sSource, aoData, fnCallback ) {
                var pageSize = aoData[4].value;
                var pageIndex = aoData[3].value/pageSize+1;

                $.ajax({
                    type: "post",
                    dataType:'json', //接受数据格式
                    cache:false,
                    data : aoData,
                    //data : {
                    //    page : pageIndex,
                    //    size : pageSize,
                    //    contestId : $.getUrlParam('contestId')
                    //},
                    url: sSource,
                    success: function(data, textStatus){
                        var r = {
                            iTotalRecords : 50,
                            iTotalDisplayRecords : 50,
                            aaData : []
                        }
                        if(data instanceof Array){
                            r.aaData = data;
                        }else{
                            // var t ={};
                            // t.aaData = data.data;
                            // t.iTotalDisplayRecords = data.iTotalRecords;
                            // r =t;
                            data.aaData = data.data.resPrizeInfo;
                            data.iTotalDisplayRecords = data.data.resPrizeInfo.length;
                            r = data;

                            $scope.$apply(function(){
                                $scope.cur_contest = data.data.contestInfo;
                                $scope.cur_prizes = angular.copy($scope.cur_contest.prizes);
                            });
                        }
                        fnCallback(r);
                    },
                    error: function(){
                        //请求出错处理
                        // alert("error");
                    }
                });

            }, //获取数据的处理函数
            "sPaginationType": "full_numbers", //翻页界面类型
            "headerClickable":false,
            "sortable":false/*,
             data: cur_result ||[{
             title: 'aa',
             createdTime: 'bb',
             itemCount: 3,
             state: 1,
             recommendation: 3,
             rating: 0
             }]*/
//         "sDom": "<'pull-right'l>t<'row'<'col-lg-6'f><'col-lg-6'p>>",
//         "sPaginationType": "bootstrap",
//         "oLanguage": {
//             "sLengthMenu": "Show _MENU_ entries"
//         }
        });
    }








    //导出excel测试代码
    $scope.exportExcel = function(){
        //encodeURI  encodeURIComponent
        var exportUrl = '/contests/contest/works/export_excel?contestId=' + $.getUrlParam('contestId') + "&categoryId=" +$scope.searchResult.categoryId +
            "&stepId=" + $scope.searchResult.stepId + "&privacy=" + $scope.searchResult.privacy + "&state=" + $scope.searchResult.state  + "&queryName=" + $scope.searchResult.queryName + "&queryValue=" + encodeURI($scope.searchResult.queryValue) +"&contestName=" + encodeURI( $scope.contestDetail.title);

        $("#export-iframe").append("<iframe id='ifr' style='display:none;' src='"+ exportUrl + "'></iframe>");

    }







    var contestId = $.getUrlParam('contestId');
    //先获取大赛的基本信息

    var postData = {
        contestId : contestId
    };
    //angularJS写法  使用$http 的异步调用方法之后，返回结果就不需要调用$scope.$apply方法了
    $http.post('/contests/contest/detail', postData)
        .success(function(data){
            if(data.status == '200'){
                var cur_contest = data;
                if(typeof(cur_contest) != 'undefined'){
                    if (cur_contest instanceof Array && cur_contest.length) {
                        $scope.contestDetail = cur_contest[0];
                    }else{
                        cur_contest.data.title = sjApp.htmldecode(cur_contest.data.title);
                        $scope.contestDetail = cur_contest.data;

                        $scope._contestDetailLink = host + '/page/contestv/views/index?id=' + cur_contest.data.id + '&r='+ cur_contest.data.refer + '&p=index' ;
                    }
                }

            }else if(data.status == '302'){
                layer.msg('您没有该权限');
            }else{
                layer.msg('服务器错误', {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    //do something

                });
            }
        });





    $('#dataTable').dataTable({
        language: {
            "sProcessing": "处理中...",
            "sLengthMenu": "显示 _MENU_ 项结果",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
            "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
            "sInfoFiltered": "",//(由 _MAX_ 项结果过滤)
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        },
        /*aoColumns:[ //设定各列宽度
         {"sWidth": "10%"},
         {"sWidth": "30%"},
         {"sWidth": "30%"},
         {"sWidth": "30%"}
         ],
         <th>大赛名称</th>
         <th>创建时间</th>
         <th>作品数量</th>
         <!--<th>参赛人数</th>-->
         <th>当前状态</th>
         <th>推荐</th>
         <th>权重</th>
         <th>管理</th>*/
        columns: [
            {title: '作品编号', data: 'id', "mRender" : function(data, type, full) {
                var rHtml = '<a href="' + host + '/community/photo-details/' + full.id + '" target="_blank">' + data + '</a>';
                return rHtml;
            }},
            {
                title : '缩略图',
                data : 'url',
                "mRender" : function(data, type, full) {
                    if (data) {
                        var rHtml = '<img style="height:100px;width:auto;" src="' + data.p1 + '"/>';
                        return rHtml;
                    }
                }
            },
            {title: '作品名称',data: 'title', "mRender" : function(data, type, full) {
                return data?data:'--';
            }},
            {
                title: '用户名', data: 'userInfo', "mRender" : function(data, type, full) {
                var userName = data.nickName?data.nickName:'--';
                var rHtml = '<a href="' + host + '/community/user-details/' + data.id + '" target="_blank">' + userName + '</a>';
                return rHtml;
                //return data.nickName?data.nickName:'--';
            }},
            {
                title: '用户编号', data: 'userInfo', "mRender" : function(data, type, full) {
                return data.id?data.id:'--';
            }},
            {title: '邮箱',data: 'userInfo', "mRender" : function(data, type, full) {
                return data.email?data.email:'--';
            }},
            {title: '电话',data: 'userInfo', "mRender" : function(data, type, full) {
                return data.phone?data.phone:'--';
            }},
            {title: '参赛类别',data: 'ContestCategoryInfo', "mRender" : function(data, type, full) {
                return data?data.name:'';
            }},
            {title: '奖项',data: 'prizeNameList', "mRender" : function(data, type, full) {
                var rHtml = '';
                if(data && data instanceof Array && data.length > 0){
                    var color = '#000';
                    data.map(function(item, index){
                        rHtml = rHtml + '<span style="color: ' + color +'">'+ item.prizeName +  '</span><br/><br/>';
                        if(color == '#000'){
                            color = 'grey';
                        }else {
                            color = '#000';
                        }
                    });
                }else {
                    rHtml = '--';
                }
                return rHtml;
            }},
            {title: '状态',data: 'privacy', "mRender" : function(data, type, full) {
                if(data && data == 2){
                    return '<span style="color:blue">隐藏</span>'
                }else {
                    return '公开';
                }

            }
                // ,createdCell: function (td, cellData, rowData, row, col) {
                //    if(rowData.privacy == 2){
                //        $(td).html('<span style="color:yellow">隐藏</span>&nbsp;&nbsp;');
                //        var stateActionButtonEl = $('<a class="btn btn-metis-6 btn-xs btn-line">公开作品</a>');
                //        stateActionButtonEl.click(function(){
                //            $scope.openWork();
                //        });
                //        $(td).append(stateActionButtonEl);
                //    }else {
                //        return $(td).html('公开')
                //    }
                //}bVisible :false,
            },
            {title: '用户举报',data: 'state',
                "mRender" : function(data, type, full) {
                    if(data && data == 1){
                        return '<span style="color:blue">被举报</span>'
                    }else {
                        return '正常';
                    }

                }},
            {
                title: '勋章',
                "data": null,
                "orderable": false,
                createdCell: function (td, cellData, data, row, col) {
                    var medalButtonEl = '';
                    var medalInputEl = '';
                    var winner = '优秀获奖作品';
                    $(td).html('');
                    if((data.honorInfo != null) && (data.honorInfo.contest != null)){
                        if((!data.honorInfo.contest.flag || (!!data.recommend && !data.recommend.contest.flag))) {
                            medalButtonEl = $('<a class="btn btn-metis-6 btn-xs btn-line">赐予勋章</a>');
                            medalButtonEl.click(function(){
                                $scope.getWorkMedal(data.id,$.getUrlParam('contestId'),winner);
                            });

                        } else {
                            medalButtonEl = $('<a class="btn btn-danger btn-xs btn-line">剥夺勋章</a>');
                            medalButtonEl.click(function(){
                                $scope.setWorkMedal(data.id);
                            });
                        }
                    }else {
                        medalButtonEl = $('<a class="btn btn-metis-6 btn-xs btn-line">赐予勋章</a>');
                        medalButtonEl.click(function(){
                            $scope.getWorkMedal(data.id,$.getUrlParam('contestId'),winner);
                        });
                    }
                    $(td).append(medalInputEl);
                    $(td).append(medalButtonEl);
                }
            },
            {
                title : '操作',
                "data": null,
                "orderable": false,
                //"defaultContent": "<button>删除</button>&nbsp;<button>编辑</button>",
                createdCell: function (td, cellData, rowData, row, col) {
                    var openButtonEl = '';
                    $(td).html('');
                    var detailEl = $('<a class="btn btn-metis-6 btn-xs btn-line">更多信息</a>');
                    var quitEl = $('<a class="btn btn-danger btn-xs btn-line">强制退赛</a>&nbsp;&nbsp;');
                    if(rowData.privacy == 2){ //隐藏
                        openButtonEl = $('<a class="btn btn-metis-6 btn-xs btn-line">公开作品</a>');
                        openButtonEl.click(function(){
                            $scope.setWorkPrivacy(rowData.id,$.getUrlParam('contestId'),1);
                        });
                    }else {
                        openButtonEl = $('<a class="btn btn-metis-6 btn-xs btn-line">隐藏作品</a>');
                        openButtonEl.click(function(){
                            $scope.setWorkPrivacy(rowData.id,$.getUrlParam('contestId'),2);
                        });
                    }
                    var prizeEditEl = $('<a class="btn btn-metis-6 btn-xs btn-line">奖项设置</a>');




                    $(td).append(detailEl);
                    $(td).append('&nbsp;&nbsp');
                    $(td).append(quitEl);
                    $(td).append('&nbsp;&nbsp');
                    $(td).append(openButtonEl);
                    $(td).append('&nbsp;&nbsp');
                    $(td).append(prizeEditEl);
                    $(td).append('&nbsp;&nbsp');


                    detailEl.click(function(){
                        $scope.showDetail(rowData.id);
                    });
                    quitEl.click(function(){
                        $scope.quitContest(rowData.id, $.getUrlParam('contestId'));
                    });
                    prizeEditEl.click(function(){
                        $scope.$apply(function(){
                            $scope.resource_prizeTable = rowData;
                            $scope.objAddPrize.resourceId = rowData.id;
                        })

                        $scope.setPrizeShowWin(rowData.id, $.getUrlParam('contestId'));
                    });
                    /*editEl.click(function(){
                     var rowD = rowData;
                     return function(){
                     $scope.edit_role(rowD);
                     }
                     }());*/
                    //$(td).append('&nbsp;<a href="/community/contest/config/review?id='+rowData.id+'" class="btn btn-metis-6 btn-xs btn-line">评审</a>');
                }
            }
        ],
        "bSort": false,
        "bProcessing": true, //加载数据时显示正在加载信息
        "bServerSide": true, //指定从服务器端获取数据
        "bFilter": false, //不使用过滤功能
        "bLengthChange": false, //用户不可改变每页显示数量
        "iDisplayLength": 16, //每页显示10条数据
        "sAjaxSource": '/contests/contestV2/maintenance/getWorkList',
        "fnServerParams" : function (aoData) {
            var pageSize = aoData[4].value;
            var pageIndex = aoData[3].value/pageSize+1;
            if($scope.isSearchAdditional){
                aoData.push(
                    {"name":"contestId","value":$.getUrlParam('contestId')},
                    {"name":"page","value":pageIndex},
                    {"name":"size","value":pageSize},
                    { "name": "categoryId", "value": $scope.searchResult.categoryId},
                    { "name": "stepId", "value": $scope.searchResult.stepId},
                    { "name": "privacy", "value": $scope.searchResult.privacy},
                    { "name": "state", "value": $scope.searchResult.state},
                    { "name": "queryName", "value": $scope.searchResult.queryName},
                    { "name": "queryValue", "value": $scope.searchResult.queryName != 'prizeId'?($scope.searchQueryValueSend):$scope.searchResult.prizeId},
                    { "name": "medal", "value": $scope.searchResult.medal}
                );
            }else {
                aoData.push(
                    {"name":"contestId","value":$.getUrlParam('contestId')},
                    {"name":"page","value":pageIndex},
                    {"name":"size","value":pageSize},
                    { "name": "categoryId", "value": $scope.searchResult.categoryId},
                    { "name": "stepId", "value": $scope.searchResult.stepId},
                    { "name": "privacy", "value": $scope.searchResult.privacy},
                    { "name": "state", "value": $scope.searchResult.state},
                    { "name": "medal", "value": $scope.searchResult.medal}
                );
            }

        },
        "fnServerData": function( sSource, aoData, fnCallback ) {
            var pageSize = aoData[4].value;
            var pageIndex = aoData[3].value/pageSize+1;

            $.ajax({
                type: "post",
                dataType:'json', //接受数据格式
                cache:false,
                data : aoData,
                //data : {
                //    page : pageIndex,
                //    size : pageSize,
                //    contestId : $.getUrlParam('contestId')
                //},
                url: sSource,
                success: function(data, textStatus){
                    var r = {
                        iTotalRecords : 50,
                        iTotalDisplayRecords : 50,
                        aaData : []
                    }
                    if(data instanceof Array){
                        r.aaData = data;
                    }else{
                        // var t ={};
                        // t.aaData = data.data;
                        // t.iTotalDisplayRecords = data.iTotalRecords;
                        // r =t;
                        data.aaData = data.data;
                        data.iTotalDisplayRecords = data.searchHitsTotal;
                        r = data;
                    }
                    fnCallback(r);
                },
                error: function(){
                    //请求出错处理
                    // alert("error");
                }
            });

        }, //获取数据的处理函数
        "sPaginationType": "full_numbers", //翻页界面类型
        "headerClickable":false,
        "sortable":false/*,
         data: cur_result ||[{
         title: 'aa',
         createdTime: 'bb',
         itemCount: 3,
         state: 1,
         recommendation: 3,
         rating: 0
         }]*/
//         "sDom": "<'pull-right'l>t<'row'<'col-lg-6'f><'col-lg-6'p>>",
//         "sPaginationType": "bootstrap",
//         "oLanguage": {
//             "sLengthMenu": "Show _MENU_ entries"
//         }
    });














});